<script lang="ts" setup>
	import { onShow, onHide, onLaunch} from '@dcloudio/uni-app';
	import { useAppStore,useUserStore } from '@/store';
	import { getToken } from '@/utils/auth';
	import { pages } from '@/utils/page-url';
	
	// 应用store
	const appStore = useAppStore();
	// 用户store
	const userStore = useUserStore();
	
	onLaunch(async () => {
		console.log('App Launch')
		// 判断是否有token
		if (await getToken()) {
			// 获取用户信息
			await userStore.info();
			// @ts-ignore
			uni.$uv.route({
				type: 'reLaunch',
				url: pages.home
			})
		} else {
			if (!appStore.loginAuth) {
				// @ts-ignore
				uni.$uv.route({
					type: 'reLaunch',
					url: pages.home
				})
			}
		}
	});
	onShow(() => {
		console.log('App Show')
		
	});
	onHide(() => {
		console.log('App Hide')
	});
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uv-ui-tools/index.scss';
	page {
		background-color: #f8f8f8;
	}
</style>
